package com.pine.app.module.security.oauth.provider;

import com.pine.app.module.security.core.AbstractAuthenticationToken;
import com.pine.app.module.security.core.userdetails.UserDetails;
import lombok.Data;

/**
 * @author xiaoyuan
 * @create 2019/10/8 10:43
 **/
@Data
public class OAuth2Authentication extends AbstractAuthenticationToken {

    private OAuth2ClientRequest tokenRequest;

    private UserDetails userDetails;

    private boolean enableRefresh;
    public OAuth2Authentication(){
        super();
    }
    public OAuth2Authentication(OAuth2ClientRequest tokenRequest,UserDetails userDetails){
        super();
        this.tokenRequest = tokenRequest;
        this.userDetails = userDetails;
    }
    public boolean isClientOnly() {
        return this.userDetails == null;
    }
    @Override
    public Object getCredentials() {
        return tokenRequest;
    }

    @Override
    public Object getPrincipal() {
        return userDetails;
    }
}
